﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using ihongma.Common;

namespace ihongma.test
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
          //  DateTime date =new DBNull;
            //string str = DESEncrypt.Decrypt("50C215BB3B599960");
            //Response.Write(str);
            //StringBuilder sb = new StringBuilder();
            //                var str=MilliTimeStamp(DateTime.Now).ToString();
            //                Response.Write(jsontostring(str));
            //string str = "3,3,4,5,5,6,6,6,";
            //foreach (var dd  in str.Split(','))
            //{
            //    sb.Append("{");
            //    sb.AppendFormat("\"id\":{0},\"q\":{1}", dd, dd);
            //    sb.Append("},");
            //}
            //Response.Write(sb.ToString());
        }
        public static string jsontostring(string temp_json)
        {
            return temp_json = System.Text.RegularExpressions.Regex.Replace(temp_json, "e\\\":(\\d+)", match =>
            {
                DateTime dt = new DateTime(1970, 1, 1);
                dt = dt.AddMilliseconds(long.Parse(match.Groups[1].Value));
                dt = dt.ToLocalTime();
                return "e\":" + dt.ToString("yyyy-MM-dd HH:mm:ss");
            });
        }
        public long MilliTimeStamp(DateTime TheDate)
        {
            DateTime d1 = new DateTime(1970, 1, 1);
            DateTime d2 = TheDate.ToUniversalTime();
            TimeSpan ts = new TimeSpan(d2.Ticks - d1.Ticks);
            return (long)ts.TotalMilliseconds;
        }
    }
}